import { setStorage } from '@/utils/storage';

Page({

  data: {
    order: {},
    orderId: '',
    createTime: ''
  },

  onLoad(options) {
    const order = JSON.parse(options.order)
    this.setData({
      order: order.cartResultVO,
      orderId: order.id,
      createTime: order.createTime
    })
  },

  copyText(event) {
    const orderId = event.currentTarget.dataset.id;
    wx.setClipboardData({
      data: orderId,
      success() {
        wx.toast({ title: '已复制' });
      }
    });
  },

  handleOrderAgain(event) {
    const cart = event.target.dataset.order
    setStorage('cart', cart)
    wx.reLaunch({
      url: '../../../pages/menu/menu',
    })
  }
})